/**
 * Created by yjj on 2017/4/11.
 */
import axios from 'axios';

import {API_VERSION, API_NEW_VERSION} from '../api';

const PARTNERS = API_NEW_VERSION + 'partners';

const PARTNERS_COUNT = API_NEW_VERSION + 'partners_count';

const PARTNERS_BY_PARTNER_ID = API_NEW_VERSION + 'partners_by_partner_id';

const PARTNERS_SEARCH_OTHERS = API_NEW_VERSION + 'partners_search_others';

const PARTNERS_BY_PARTNER_ID_NO_PAGE = API_NEW_VERSION + 'partners_by_partner_id_no_page';

const PARTNERS_NO_PAGE = API_NEW_VERSION + 'partners_no_page';

// 组合搜索事业合伙人收益详细表
export const searchPattnerPorfitLogDetail = params => {
  return axios.get(PARTNERS_SEARCH_OTHERS, {params: params});
};
export const searchPattnerPorfitLogDetailNoPage = partnerId => {
  return axios.get(PARTNERS_BY_PARTNER_ID_NO_PAGE, {params: {partnerId: partnerId}});
};

// 搜索合伙人统计列表
export const searchPattners = params => {
  return axios.get(PARTNERS_COUNT, {params: params});
};
// 搜索合伙人统计列表不分页
export const searchPattnersNoPage = params => {
  return axios.get(PARTNERS_NO_PAGE, {params: params});
};

// 搜索栏，搜索合伙人姓名
export const searchPartner = params => {
  return axios.get(API_NEW_VERSION + 'partners', {params: params});
};

export const getPartners = params => {
  return axios.get(API_VERSION + PARTNERS, {params: params});
};

export const getPartner = id => {
  return axios.get(API_VERSION + `/partners/` + id);
};

export const savePartners = (token, params) => {
  return axios.post(API_VERSION + `/partners?token=` + token, params);
};

export const batchPartners = ids => {
  return axios.delete(API_VERSION + `/partners/` + ids);
};
// 根据条件搜索获取合伙人收益
export const searchPartnerProfitLog = params => {
  return axios.get(PARTNERS_BY_PARTNER_ID, {params: params});
};

export const searchDotPartners = organizationId => {
  return axios.get(API_NEW_VERSION + 'partners_dot_divide_ratio', {params: {organizationId: organizationId}});
};

export const setPartnersDotDivideRatio = params => {
  return axios.post(API_NEW_VERSION + 'partners_dot_divide_ratio', params);
};
